package com.mcxx.formulcount.gonshi;

import java.util.ArrayList;

public class FormulaConvert {
	private ArrayList<KeySymbol> allSymbol = new ArrayList<KeySymbol>(java.util.Arrays.asList(new KeySymbol[]
			{
				new KeySymbol("否则如果", "[else]▲S_L_P_T▲[if]"),
				new KeySymbol("小于等于", "≤"),
				new KeySymbol("大于等于", "≥"),
				new KeySymbol("不等于", "≠"),
				new KeySymbol("=", "∑"),
					new KeySymbol("如果", "[if]"),
					new KeySymbol("等于", "="),
					new KeySymbol("小于", "<"),
					new KeySymbol("大于", ">"),
					new KeySymbol("+", "+"),
					new KeySymbol("-", "-"),
					new KeySymbol("×", "*"),
					new KeySymbol("/", "/"),
					new KeySymbol("(", "("),
					new KeySymbol(")", ")"),
					new KeySymbol("{", "{"),
					new KeySymbol("}", "}"),
					new KeySymbol("那么", "[so]"),
					new KeySymbol("否则", "[else]"),
					new KeySymbol(";", ";"),
					new KeySymbol("\"", "'"),
					new KeySymbol("并且", "[and]"),
					new KeySymbol("或者", "[or]"),
					new KeySymbol("四舍五入", "[round]"),
					new KeySymbol("舍入", "[roundUp]"),
					new KeySymbol("值比较", "[VComp]"),
					new KeySymbol("值包含", "[VInclude]") }));
	public FormulaConvert(){


	}
	public final  ArrayList<String> SplitWord(String exp)
	{
		String tmp = exp;
		for(KeySymbol m:allSymbol ){
			 tmp = tmp.replace(m.Symbol, "▲S_L_P_T▲" + m.ToSymbol + "▲S_L_P_T▲");
		}
		String[] arr = tmp.split( "▲S_L_P_T▲" );
		ArrayList<String> rnt = new ArrayList<String>();
		for(String x : arr){
			if(!x.trim().equals("")) {
				rnt.add(x.trim());
			}
		}
		return rnt;
	}

	private String ReplaceSmb(String smb)
	{
		for(KeySymbol k : allSymbol)
		{
			if (smb.equals(k.getSymbol()))
			{
				return k.getToSymbol();
			}
		}
		return smb;
	}

}
